/*
 * @Description: 页面说明
 * @Version: 版本号
 * @Author: chuzhangyi
 * @Date: 2022-09-14 10:26:29
 * @LastEditors: 最后一次编辑说明
 * @LastEditTime: 2022-09-14 14:11:16
 * @FilePath: \adminc:\Users\dell\Desktop\react (1)\新建文件夹\react\src\view\index\detail.jsx
 */
import React, { Component } from 'react';
import { connect } from 'react-redux'
import qs from "querystring"
import store from '../../store/index.js'
// 引入action
import { setPageTitle, setInfoList } from '../../store/actions.js'
class Detail extends Component {
  constructor(props) {
    super(props)
    this.state = {
      title: store.getState().pageTitle
    };
    this.query = qs.parse(this.props.location.search.slice(1));
  };
  componentDidMount() {
    // let searchData = qs.parse(this.props.location.search.slice(1))
    this.query.name = 'cfcff';
    // console.log(this.props, this.query)
  };
  render(h) {
    console.log(this.props)
    return (
      <div>
        <h2 onClick={() => {this.props.setPageTitle('撒大苏打') }}>详情修改store值</h2>
        <p>store.pageTitle： {this.props.pageTitle}</p>
      </div>

    )
  }
}
// mapStateToProps：将state映射到组件的props中
const mapStateToProps = (state) => {
  return {
    pageTitle: state.pageTitle,
    infoList: state.infoList
  }
}

// mapDispatchToProps：将dispatch映射到组件的props中
const mapDispatchToProps = (dispatch, ownProps) => {
  return {
    setPageTitle(data) {
      // 如果不懂这里的逻辑可查看前面对redux-thunk的介绍
      dispatch(setPageTitle(data))
    },
    setInfoList(data) {
      dispatch(setInfoList(data))
    }
  }
}
export default connect(mapStateToProps, mapDispatchToProps)(Detail);
// export default Detail